package com.ep.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ep.common.utils.PageUtils;
import com.ep.modules.app.dao.AppTaskDiscussionMapper;
import com.ep.modules.app.entity.AppTaskDiscussion;
import com.ep.modules.app.entity.AppTaskDiscussionExample;
import com.ep.modules.app.service.AppTaskDiscussionService;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AppTaskDiscussionServiceImpl implements AppTaskDiscussionService {
    @Autowired
    private AppTaskDiscussionMapper appTaskDiscussionMapper;

    public PageUtils queryPage(Map<String, Object> params) {
        String searchKey = (String)params.get("searchKey");
        Long searchUserId = (Long)params.get("searchUserId");
        AppTaskDiscussionExample example = new AppTaskDiscussionExample();
        AppTaskDiscussionExample.Criteria criteria = example.createCriteria();
        List<AppTaskDiscussion> list = appTaskDiscussionMapper.selectByExample(example);
        Page<AppTaskDiscussion> page = new Page<>();
        page.setRecords(list);
        return new PageUtils(page);
    }

    public AppTaskDiscussion getById(Long id) {
        return appTaskDiscussionMapper.selectByPrimaryKey(id.intValue());
    }

    public void save(AppTaskDiscussion entity) {
        appTaskDiscussionMapper.insert(entity);
    }

    public void update(AppTaskDiscussion entity) {
        appTaskDiscussionMapper.updateByPrimaryKeySelective(entity);
    }

    public void deleteBatch(Long[] ids) {
        for (Long id : ids) {
                appTaskDiscussionMapper.deleteByPrimaryKey(id.intValue());
        }
    }
}